home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-egevang-addrtrans-01.txt < prev    next >
Text File  |  1993-06-07  |  23KB  |  620 lines

  1.  
  2.  
  3. Network Working Group                          Kjeld Borch Egevang
  4. Internet Draft                                 Cray Communications
  5. Expiration Date: November 1993                        Paul Francis
  6.                                                (formerly Tsuchiya)
  7.                                                           Bellcore
  8.                                                           May 1993
  9.  
  10.  
  11.                 The IP Network Address Translator (NAT)
  12.  
  13. Status of this Memo
  14.  
  15.    This document is an Internet Draft. Internet Drafts are working
  16.    documents of the Internet Engineering Task Force (IETF), its Areas,
  17.    and its Working Groups. Note that other groups may also distribute
  18.    working documents as Internet Drafts.
  19.  
  20.    Internet Drafts are draft documents valid for a maximum of six
  21.    months. Internet Drafts may be updated, replaced, or obsoleted by
  22.    other documents at any time. It is not appropriate to use Internet
  23.    Drafts as reference material or to cite them other than as a
  24.    ``working draft'' or ``work in progress.'' Please check the 1id-
  25.    abstracts.txt listing contained in the internet-drafts Shadow
  26.    Directories on nic.ddn.mil, nnsc.nsf.net, nic.nordu.net,
  27.    ftp.nisc.sri.com, or munnari.oz.au to learn the current status of any
  28.    Internet Draft.
  29.  
  30.    This memo describes a solution to the IP address depletion problem -
  31.    address translation. Address translation would be a purely local
  32.    matter, and would not affect other networks. Therefore, the use of
  33.    such a technique is entirely discretionary.
  34.  
  35.    This memo provides information for the Internet community. It does
  36.    not specify an Internet standard. Distribution of this memo is
  37.    unlimited.
  38.  
  39. Abstract
  40.  
  41.    The two most compelling problems facing the IP Internet are IP
  42.    address depletion and scaling in routing. Long-term and short-term
  43.    solutions to these problems are being developed. The short-term
  44.    solution is CIDR (Classless InterDomain Routing). The long-term
  45.    solutions consist of various proposals for new internet protocols
  46.    with larger addresses.
  47.  
  48.    It is possible that CIDR will not be adequate to maintain the IP
  49.    internet until the long-term solutions are in place. This memo
  50.    proposes another short-term solution, address reuse, that complements
  51.    CIDR or even makes it unnecessary. The address reuse solution is to
  52.    place Network Address Translators (NAT) at the borders of stub
  53.    domains. Each NAT box has a table consisting of pairs of local IP
  54.    addresses and globally unique addresses. The IP addresses inside the
  55.  
  56.  
  57.  
  58. Egevang, Francis                                                [Page 1]
  59.  
  60. Internet Draft         Network Address Translator               May 1993
  61.  
  62.  
  63.    stub domain are not globally unique. They are reused in other
  64.    domains, thus solving the address depletion problem. The globally
  65.    unique IP addresses are assigned according to current CIDR address
  66.    allocation schemes. CIDR solves the scaling problem. The main
  67.    advantage of NAT is that it can be installed without changes to
  68.    routers or hosts. This memo presents a preliminary design for NAT,
  69.    and discusses its pros and cons.
  70.  
  71. Acknowledgments
  72.  
  73.    This memo is based on a paper by Paul Francis (formerly Tsuchiya) and
  74.    Tony Eng, published in Computer Communication Review, January 1993.
  75.    Paul had the concept of address reuse from Van Jacobson.
  76.  
  77.    Kjeld Borch Egevang edited the paper to produce this memo and
  78.    introduced adjustment of sequence-numbers for FTP. Thanks to Jacob
  79.    Michael Christensen for his comments on the idea and text (we thought
  80.    for a long time, we were the only ones who had had the idea).
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Egevang, Francis                                                [Page 2]
  115.  
  116. Internet Draft         Network Address Translator               May 1993
  117.  
  118.  
  119. 1. Introduction
  120.  
  121.    The two most compelling problems facing the IP Internet are IP
  122.    address depletion and scaling in routing. Long-term and short-term
  123.    solutions to these problems are being developed. The short-term
  124.    solution is CIDR (Classless InterDomain Routing) [Fu]. The long-term
  125.    solutions consist of various proposals for new internet protocols
  126.    with larger addresses.
  127.  
  128.    Until the long-term solutions are ready an easy way to hold down the
  129.    demand for IP addresses is through address reuse. This solution takes
  130.    advantage of the fact that a very small percentage of hosts in a stub
  131.    domain are communicating outside of the domain at any given time. (A
  132.    stub domain is a domain, such as a corporate network, that only
  133.    handles traffic originated or destined to hosts in the domain).
  134.    Indeed, many (if not most) hosts never communicate outside of their
  135.    stub domain. Because of this, only a subset of the IP addresses
  136.    inside a stub domain, need be translated into IP addresses that are
  137.    globally unique when outside communications is required.
  138.  
  139.    This solution has the disadvantage of taking away the end-to-end
  140.    significance of an IP address, and making up for it with increased
  141.    state in the network. There are various work-arounds that minimize
  142.    the potential pitfalls of this. Indeed, connection-oriented protocols
  143.    are essentially doing address reuse at every hop.
  144.  
  145.    The huge advantage of this approach is that it can be installed
  146.    incrementally, without changes to either hosts or routers. (A few
  147.    unusual applications may require changes). As such, this solution can
  148.    be implemented and experimented with quickly. If nothing else, this
  149.    solution can serve to provide temporarily relief while other, more
  150.    complex and far-reaching solutions are worked out.
  151.  
  152. 2. Overview of NAT
  153.  
  154.    The design presented in this memo is called NAT, for Network Address
  155.    Translator. NAT is a router function that can be configured as shown
  156.    in figure 1. Only the stub border router requires modifications.
  157.  
  158.    NAT's basic operation is as follows. The addresses inside a stub
  159.    domain can be reused by any other stub domain. For instance, a single
  160.    Class A address could be used by many stub domains. At each exit
  161.    point between a stub domain and backbone, NAT is installed. If there
  162.    is more than one exit point it is of great importance that each NAT
  163.    has the same translation table.
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170. Egevang, Francis                                                [Page 3]
  171.  
  172. Internet Draft         Network Address Translator               May 1993
  173.  
  174.  
  175.         \ | /                 .                                /
  176.    +---------------+  WAN     .           +-----------------+/
  177.    |Regional Router|----------------------|Stub Router w/NAT|---
  178.    +---------------+          .           +-----------------+\
  179.                               .                      |         \
  180.                               .                      |  LAN
  181.                               .               ---------------
  182.                         Stub border
  183.  
  184.    Figure 1: NAT Configuration
  185.  
  186.  
  187.    For instance, in the example of figure 2, both stubs A and B
  188.    internally use class A address 42.0.0.0. Stub A's NAT is assigned the
  189.    class C address 198.76.29.0, and Stub B's NAT is assigned the class C
  190.    address 198.76.28.0. The class C addresses are globally unique no
  191.    other NAT boxes can use them.
  192.  
  193.  
  194.                                        \ | /
  195.                                      +---------------+
  196.                                      |Regional Router|
  197.                                      +---------------+
  198.                                    WAN |           | WAN
  199.                                        |           |
  200.                    Stub A .............|....   ....|............ Stub B
  201.                                        |           |
  202.                      {s=198.76.29.7,^  |           |  v{s=198.76.29.7,
  203.                       d=198.76.28.4}^  |           |  v d=198.76.28.4}
  204.                        +-----------------+       +-----------------+
  205.                        |Stub Router w/NAT|       |Stub Router w/NAT|
  206.                        +-----------------+       +-----------------+
  207.                              |                         |
  208.                              |  LAN               LAN  |
  209.                        -------------             -------------
  210.                                  |                 |
  211.                {s=42.33.96.5, ^  |                 |  v{s=198.76.29.7,
  212.                 d=198.76.28.4}^ +--+             +--+ v d=42.81.13.22}
  213.                                 |--|             |--|
  214.                                /____\           /____\
  215.                              42.33.96.5       42.81.13.22
  216.  
  217.    Figure 2: Basic NAT Operation
  218.  
  219.  
  220.    When stub A host 42.33.96.5 wishes to send a packet to stub B host
  221.    42.81.13.22, it uses the globally unique address 198.76.28.4 as
  222.    destination, and sends the packet to it's primary router. The stub
  223.  
  224.  
  225.  
  226. Egevang, Francis                                                [Page 4]
  227.  
  228. Internet Draft         Network Address Translator               May 1993
  229.  
  230.  
  231.    router has a static route for net 198.76.0.0 so the packet is
  232.    forwarded to the WAN-link. However, NAT translates the source address
  233.    42.33.96.5 of the IP header with the globally unique 198.76.29.7
  234.    before the package is forwarded. Likewise, IP packets on the return
  235.    path go through similar address translations.
  236.  
  237.    Notice that this requires no changes to hosts or routers. For
  238.    instance, as far as the stub A host is concerned, 198.76.28.4 is the
  239.    address used by the host in stub B. The address translations are
  240.    completely transparent.
  241.  
  242.    Of course, this is just a simple example. There are numerous issues
  243.    to be explored. In the next section, we discuss various aspects of
  244.    NAT.
  245.  
  246. 3. Various Aspects of NAT
  247.  
  248. 3.1 Address Spaces
  249.  
  250. Partitioning of Reusable and Non-reusable Addresses
  251.  
  252.    For NAT to operate properly, it is necessary to partition the IP
  253.    address space into two parts - the reusable addresses used internal
  254.    to stub domains, and the globally unique addresses. We call the
  255.    reusable address local addresses, and the globally unique addresses
  256.    global addresses. Any given address must either be a local address or
  257.    a global address. There is no overlap.
  258.  
  259.    The problem with overlap is the following. Say a host in stub A
  260.    wished to send packets to a host in stub B, but the local addresses
  261.    of stub B overlapped the local addressees of stub A. In this case,
  262.    the routers in stub A would not be able to distinguish the global
  263.    address of stub B from its own local addresses.
  264.  
  265. Initial Assignment of Local and Global Addresses
  266.  
  267.    A single class A address should be allocated for local networks. This
  268.    address could then be used for internets with no connection to the
  269.    Internet. NAT then provides an easy way to change an experimental
  270.    network to a "real" network by translating the experimental addresses
  271.    to globally unique Internet addresses.
  272.  
  273.    Existing stubs which have unique addresses assigned internally, but
  274.    are running out of them, can change addresses subnet by subnet to
  275.    local addresses. The freed adresses can then be used by NAT for
  276.    external communications.
  277.  
  278.  
  279.  
  280.  
  281.  
  282. Egevang, Francis                                                [Page 5]
  283.  
  284. Internet Draft         Network Address Translator               May 1993
  285.  
  286.  
  287. 3.2 Routing Across NAT
  288.  
  289.    The router running NAT should never advertise the local networks to
  290.    the backbone. Only the networks with global addresses may be known
  291.    outside the stub. However, global information that NAT receives from
  292.    the stub border router can be advertised in the stub the usual way.
  293.  
  294. Private Networks that Span Backbones
  295.  
  296.    In many cases, a private network (such as a corporate network) will
  297.    be spread over different locations and will use a public backbone for
  298.    communications between those locations. In this case, it is not
  299.    desirable to do address translation, both because large numbers of
  300.    hosts may want to communicate across the backbone, thus requiring
  301.    large address tables, and because there will be more applications
  302.    that depend on configured addresses, as opposed to going to a name
  303.    server. We call such a private network a backbone-partitioned stub.
  304.  
  305.    Backbone-partitioned stubs should behave as though they were a non-
  306.    partitioned stub. That is, the routers in all partitions should
  307.    maintain routes to the local address spaces of all partitions. Of
  308.    course, the (public) backbones do not maintain routes to any local
  309.    addresses. Therefore, the border routers must tunnel through the
  310.    backbones using encapsulation. To do this, each NAT box will set
  311.    aside one global address for tunneling. When a NAT box x in stub
  312.    partition X wishes to deliver a packet to stub partition Y, it will
  313.    encapsulate the packet in an IP header with destination address set
  314.    to the global address of NAT box y that has been reserved for
  315.    encapsulation. When NAT box y receives a packet with that destination
  316.    address, it decapsulates the IP header and routes the packet
  317.    internally.
  318.  
  319. 3.3 Header Manipulations
  320.  
  321.    In addition to modifying the IP address, NAT must modify the IP
  322.    checksum and the TCP checksum. Remember, TCP's checksum also covers a
  323.    pseudo header which contains the source and destination address. NAT
  324.    must also look out for ICMP and FTP and modify the places where the
  325.    IP address appears. There are undoubtedly other places, where
  326.    modifications must be done. Hopefully, most such applications will be
  327.    discovered during experimentation with NAT.
  328.  
  329.    The checksum modifications to IP and TCP are simple and efficient.
  330.    Since both use a one's complement sum, it is sufficient to calculate
  331.    the arithmetic difference between the before-translation and after-
  332.    translation addresses and add this to the checksum. The only tricky
  333.    part is determining whether the addition resulted in a wrap-around
  334.    (in either the positive or negative direction) of the checksum. If
  335.  
  336.  
  337.  
  338. Egevang, Francis                                                [Page 6]
  339.  
  340. Internet Draft         Network Address Translator               May 1993
  341.  
  342.  
  343.    so, 1 must be added or subtracted to satisfy the one's complement
  344.    arithmetic. Sample code (in C) for this is as follows:
  345.  
  346.  
  347. void checksumadjust(unsigned char *chksum, unsigned char *optr,
  348. int olen, unsigned char *nptr, int nlen)
  349. /* assuming: unsigned char is 8 bits, long is 32 bits.
  350.   - chksum points to the chksum in the packet
  351.   - optr points to the old data in the packet
  352.   - nptr points to the new data in the packet
  353. */
  354. {
  355.   long x, old, new;
  356.   x=chksum[0]*256+chksum[1];
  357.   x=~x;
  358.   while (olen) {
  359.     if (olen==1) {
  360.       old=optr[0]*256+optr[1];
  361.       x-=old & 0xff00;
  362.       if (x<=0) { x--; x&=0xffff; }
  363.       break;
  364.     }
  365.     else {
  366.       old=optr[0]*256+optr[1]; optr+=2;
  367.       x-=old & 0xffff;
  368.       if (x<=0) { x--; x&=0xffff; }
  369.       olen-=2;
  370.     }
  371.   }
  372.   while (nlen) {
  373.     if (nlen==1) {
  374.       new=nptr[0]*256+nptr[1];
  375.       x+=new & 0xff00;
  376.       if (x & 0x10000) { x++; x&=0xffff; }
  377.       break;
  378.     }
  379.     else {
  380.       new=nptr[0]*256+nptr[1]; nptr+=2;
  381.       x+=new & 0xffff;
  382.       if (x & 0x10000) { x++; x&=0xffff; }
  383.       nlen-=2;
  384.     }
  385.   }
  386.   x=~x;
  387.   chksum[0]=x/256; chksum[1]=x & 0xff;
  388. }
  389.  
  390.  
  391.  
  392.  
  393.  
  394. Egevang, Francis                                                [Page 7]
  395.  
  396. Internet Draft         Network Address Translator               May 1993
  397.  
  398.  
  399.    The arguments to the File Transfer Protocol (FTP) PORT command
  400.    include an IP address (in ASCII!). If the IP address in the PORT
  401.    command is local to the stub domain, then NAT must substitute this.
  402.    Because the address is encoded in ASCII, this may result in a change
  403.    in the size of the packet (for instance 10.18.177.42 is 12 ASCII
  404.    characters, while 193.45.228.137 is 14 ASCII characters). If the new
  405.    size is the same as the previous, only the TCP checksum needs
  406.    adjustment (again). If the new size is less than the previous, ASCII
  407.    zeroes may be inserted, but this is not guaranteed to work. If the
  408.    new size is larger than the previous, TCP sequence numbers must be
  409.    changed too.
  410.  
  411.    A special table is used to correct the TCP sequence and acknowledge
  412.    numbers with source port FTP or destination port FTP. The table
  413.    entries should have source, destination, source port, destination
  414.    port, initial sequence number, delta for sequence numbers and a
  415.    timestamp. New entries are created only when FTP PORT commands are
  416.    seen. The initial sequence numbers are used to find out if the
  417.    sequence number of a packet is before or after the last FTP PORT
  418.    command (delta may be increased for every FTP PORT command). Sequence
  419.    numbers are incremented and acknowledge numbers are decremented. If
  420.    the FIN bit is set in one of the packets, the associated entry may be
  421.    deleted soon after (1 minute should be safe). Entries that have not
  422.    been used for e.g. 24 hours should be safe to delete too.
  423.  
  424.    The sequence number adjustment must be coded carefully, not to harm
  425.    performance for TCP in general. Of course, if the FTP session is
  426.    encrypted, the PORT command will fail.
  427.  
  428.    If an ICMP message is passed through NAT, it may require two address
  429.    modifications and three checksum modifications. This is because most
  430.    ICMP messages contain part of the original IP packet in the body.
  431.    Therefore, for NAT to be completely transparent to the host, the IP
  432.    address of the IP header embedded in the data part of the ICMP packet
  433.    must be modified, the checksum field of the same IP header must
  434.    correspondingly be modified, and the ICMP header checksum must be
  435.    modified to reflect the changes to the IP header and checksum in the
  436.    ICMP body. Furthermore, the normal IP header must also be modified as
  437.    already described.
  438.  
  439.    It is not entirely clear if the IP header information in the ICMP
  440.    part of the body really need to be modified. This depends on whether
  441.    or not any host code actually looks at this IP header information.
  442.    Indeed, it may be useful to provide the exact header seen by the
  443.    router or host that issued the ICMP message to aid in debugging. In
  444.    any event, no modifications are needed for the Echo and Timestamp
  445.    messages, and NAT should never need to handle a Redirect message.
  446.  
  447.  
  448.  
  449.  
  450. Egevang, Francis                                                [Page 8]
  451.  
  452. Internet Draft         Network Address Translator               May 1993
  453.  
  454.  
  455.    SNMP messages could be modified, but it is even more dubious than for
  456.    ICMP messages that it will be necessary.
  457.  
  458. Applications with IP-address Content
  459.  
  460.    Any application that carries (and uses) the IP address inside the
  461.    application will not work through NAT unless NAT knows of such
  462.    instances and does the appropriate translation. It is not possible or
  463.    even necessarily desirable for NAT to know of all such applications.
  464.    And, if encryption is used then it is impossible for NAT to make the
  465.    translation.
  466.  
  467.    It may be possible for such systems to avoid using NAT, if the hosts
  468.    in which they run are assigned global addresses. Whether or not this
  469.    can work depends on the capability of the intra-domain routing
  470.    algorithm and the internal topology. This is because the global
  471.    address must be advertised in the intra-domain routing algorithm.
  472.    With a low-feature routing algorithm like RIP, the host may require
  473.    its own class C address space, that must not only be advertised
  474.    internally but externally as well (thus hurting global scaling). With
  475.    a high-feature routing algorithm like OSPF, the host address can be
  476.    passed around individually, and can come from the NAT table.
  477.  
  478. Privacy, Security, and Debugging Considerations
  479.  
  480.    Unfortunately, NAT reduces the number of options for providing
  481.    security. With NAT, nothing that carries an IP address or information
  482.    derived from an IP address (such as the TCP-header checksum) can be
  483.    encrypted. While most application-level encryption should be ok, this
  484.    prevents encryption of the TCP header.
  485.  
  486.    On the other hand, NAT itself can be seen as providing a kind of
  487.    privacy mechanism. This comes from the fact that machines on the
  488.    backbone cannot monitor which hosts are sending and receiving traffic
  489.    (assuming of course that the application data in encrypted).
  490.  
  491.    The same characteristic that enhances privacy potentially makes
  492.    debugging problems (including security violations) more difficult. If
  493.    a host is abusing the Internet is some way (such as trying to attack
  494.    another machine or even sending large amounts of junk mail or
  495.    something) it is more difficult to pinpoint the source of the trouble
  496.    because the IP address of the host is hidden.
  497.  
  498. 4. Conclusions
  499.  
  500.    NAT may be a good short term solution to the address depletion and
  501.    scaling problems. This is because it requires very few changes and
  502.    can be installed incrementally. NAT has several negative
  503.  
  504.  
  505.  
  506. Egevang, Francis                                                [Page 9]
  507.  
  508. Internet Draft         Network Address Translator               May 1993
  509.  
  510.  
  511.    characteristics that make it inappropriate as a long term solution,
  512.    and may make it inappropriate even as a short term solution. Only
  513.    implementation and experimentation will determine its
  514.    appropriateness.
  515.  
  516. The negative characteristics are:
  517.  
  518. 1. It requires a sparse end-to-end traffic matrix. Otherwise, the NAT
  519.    tables will be large, thus giving lower performance. While the
  520.    expectation is that end-to-end traffic matrices are indeed sparse,
  521.    experience with NAT will determine whether or not they are. In any
  522.    event, future applications may require a rich traffic matrix (for
  523.    instance, distributed resource discovery), thus making long-term use
  524.    of NAT unattractive.
  525.  
  526. 2. It increases the probability of mis-addressing.
  527.  
  528. 3. It breaks certain applications (or at least makes them more difficult
  529.    to run).
  530.  
  531. 4. It hides the identity of hosts. While this has the benefit of
  532.    privacy, it is generally a negative effect.
  533.  
  534.  
  535. Current Implementations
  536.  
  537.    Paul and Tony implemented an experimental prototype of NAT on public
  538.    domain KA9Q TCP/IP software [Ka]. This implementation manipulates
  539.    addresses and IP checksums.
  540.  
  541.    Kjeld implemented NAT in a Cray Communications IP-router. The
  542.    implementation was tested with Telnet and FTP. This implementation
  543.    manipulates addresses, IP checksums, TCP sequence/acknowledge numbers
  544.    and FTP PORT commands.
  545.  
  546.    The prototypes has demonstrated that IP addresses can be translated
  547.    transparently to hosts within the limitations described in this
  548.    paper.
  549.  
  550. REFERENCES
  551.  
  552. [Ka]  Karn, P., "KA9Q", anonymous FTP from ucsd.edu
  553.       (hamradio/packet/ka9q/docs).
  554.  
  555. [Fu]  Fuller, V., Li, T., Yu, J., "Classless Inter-Domain Routing (CIDR)
  556.       an Address Assignment and Aggregation Strategy", IETF Internet
  557.       Draft, draft-fuller-cidr-strategy-01.txt, anonymous FTP from
  558.       nnsc.nsf.net, February, 1993.
  559.  
  560.  
  561.  
  562. Egevang, Francis                                               [Page 10]
  563.  
  564. Internet Draft         Network Address Translator               May 1993
  565.  
  566.  
  567. Author's Address
  568.  
  569.    Kjeld Borch Egevang
  570.    Cray Communications
  571.    Smedeholm 12-14
  572.    DK-2730 Herlev
  573.    Denmark
  574.  
  575.    Phone: +45 44 53 01 00
  576.  
  577.    Email: kbe@craynet.dk
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618. Egevang, Francis                                               [Page 11]
  619.  
  620.